package es.cea.biblioteca;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class AdminMenuServlet
 */
public class AdminMenuServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html");
		PrintWriter writer=response.getWriter();
		String accion=request.getParameter("accion");
		System.out.println("caca "+accion);
		
		//si recibo el parametro salir como true cierro la sesion
		if(accion!=null){
			System.out.println("CERRAR SESION");
			request.getSession().invalidate();
			request.getRequestDispatcher("./adminLogin").forward(request, response);
		}	
		
		
		writer.println("<html><head><title>Biblioteca - Men&uacute; principal del &aacute;rea de administraci&oacute;n</title></head>"+
				"<body bgcolor='#003366' text='#FFFFFF' leftmargin='50' link='#FFFFCC' vlink='#FF3300'>"+
				"<h2>Men&uacute; principal del &aacute;rea de administraci&oacute;n</h2><br/><br/>"+
				"<a href='./adminListaUsuarios'>Lista de Usuarios</a><br/>"+
				"<a href='./adminSolicitudes'>Lista de solicitudes de usuarios para prestamos</a><br/>"+
				"<a href='./adminPrestados'>Lista de libros prestados</a><br/>"+
				"<a href='./adminLibros'>Gestion de libros</a><br/>"+
				"<a href='./adminAutores'>Gestion de autores</a><br/>"+
				"<a href='./adminGeneros'>Gestion de generos</a><br/>"+
				"<br/><a href='./adminLogin?accion=salir'>Cerrar sesion</a><br/>"+
				"</body></html>");
		
		
		writer.close();
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request,response);
	}

}
